<template>
  <section class="oa-form__table">
    <h5>{{approve.name}}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">
            新建{{approve.name}}
          </span>
          <span v-else>
            {{approve.approve_name}}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
    <table class="achievement__tab">
       <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td>
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <!-- <td>岗位:</td> -->
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
      <tr>
        <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name" width="300">评分说明</td>
        <td class="_name">评定人</td>
        <td class="_name">自评</td>
        <td class="_name">评估</td>
        <!-- <td class="_name" width="346">事项说明</td> -->
      </tr>
      <tr>
        <td rowspan="3">行政</td>
        <td>日常事务</td>
        <td>40%</td>
        <td>
          配合执行公司大事记，包括但不限于日常迎来送往；会议管理，会议纪要3个工作日内上传OA; 收到各项月结账单、费用票据3个工作日内处理完毕；做到前台一定有人，电话响三声内必接；业务咨询电话认真登记并转对接人来访客人接待工作；客人来访主动起身热情接待;上下班巡查，保障室内办公环境干净、安全（电、门、窗关闭）（超时一次扣2分）
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a656" :disabled="obj.a656Flag" /></td>
        <td><el-input v-model="obj.a665" :disabled="obj.a665Flag" /></td>
      </tr>
      <tr>
        <td>
          办公环境维护及管 理
        </td>
        <td>10%</td>
        <td>
          物业管理处服务对接:配合督促办公设备出现故障，及时联系雄修，以确保小问题1个工作日
          大问题3个工作日内恢复使用（
          <span class="c_red">超时一-次扣2分</span>
          )
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a657" :disabled="obj.a657Flag" /></td>
        <td><el-input v-model="obj.a666" :disabled="obj.a666Flag" /></td>
      </tr>
      <tr>
        <td>办公用品管理</td>
        <td>10%</td>
        <td>
          负责办公用品的采购.确保入库、发放登记。存货等数据-致（
          <span class="c_red">出错一次扣2分</span>
          )
        </td>
        <td>主办会计</td>
        <td><el-input v-model="obj.a658" :disabled="obj.a658Flag" /></td>
        <td><el-input v-model="obj.a667" :disabled="obj.a667Flag" /></td>
      </tr>
      <tr>
        <td rowspan="2">&nbsp;</td>
        <td>考勤管理</td>
        <td>15%</td>
        <td>
          每月8日前完成天艺、三六九、完成工程考勤数据的汇总（超时一次扣2分）
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a659" :disabled="obj.a659Flag" /></td>
        <td><el-input v-model="obj.a668" :disabled="obj.a668Flag" /></td>
      </tr>
      <tr>
        <td>招聘</td>
        <td>5%</td>
        <td>
          协助人事主管完成招聘工作，每月基础岗位筛选简历90份、邀约面试28人；收到部门领导上传简历需在当天完成电话邀约；每周五需提供招聘信息表单（超时一次扣2分，少1人扣1分）
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a660" :disabled="obj.a660Flag" /></td>
        <td><el-input v-model="obj.a669" :disabled="obj.a669Flag" /></td>
      </tr>
      <tr>
        <td>活动组织</td>
        <td>活动组织</td>
        <td>10%</td>
        <td>
          每月组织全公司团建一次:周末积极带动全员运动聚会.发扬企业文化（
          <span class="c_red">
            根据员工满意度高 故完成度来评分
          </span>
          )
        </td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a661" :disabled="obj.a661Flag" /></td>
        <td><el-input v-model="obj.a670" :disabled="obj.a670Flag" /></td>
      </tr>
      <tr>
        <td>公司制度执</td>
        <td>遵守公司规章制度</td>
        <td>10%</td>
        <td>
          对公司制度及公司文化的理解和执行（
          <span class="c_red">
            包括根据公司体规划制定个人业务计划，合理安排个
            人各项工作时间。遵守公司各项制度等
          </span>
          )
        </td>
        <td>管导</td>
        <td><el-input v-model="obj.a662" :disabled="obj.a662Flag" /></td>
        <td><el-input v-model="obj.a671" :disabled="obj.a671Flag" /></td>
      </tr>
      <tr>
        <td>加分项</td>
        <td>增量工作内容</td>
        <td>&nbsp;</td>
        <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a663" :disabled="obj.a663Flag" /></td>
        <td><el-input v-model="obj.a678" :disabled="obj.a678Flag" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>对公司的建议</td>
        <td>&nbsp;</td>
        <td>对市场拓展、业务销售、内部管理等建设性意见</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a664" :disabled="obj.a664Flag" /></td>
        <td><el-input v-model="obj.a679" :disabled="obj.a679Flag" /></td>
      </tr>
      <tr>
        <td colspan="3">自评:{{myScore}}</td>
        <td colspan="5">综合考核率:{{otherScore}}</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
const obj = {}
for (let i = 656; i <= 673; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
for (let i = 678; i <= 679; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    myScore () {
      const result = []
      for (let i = 656; i <= 664; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 665; i <= 673; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      result.push(this.obj.a678)
      result.push(this.obj.a679)
      return sum(result)
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
